<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改餐厅管理')"/>
    <link th:href="@{/taginput/jquery.tagsinput-revisited.css}" rel="stylesheet"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-WxCanteen-edit" th:object="${wxCanteen}">
        <input name="canteenId" th:field="*{canteenId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">绑定用户：</label>
            <div class="col-sm-10">
                <input  id="Uid" th:value="*{canteenUid}" class="form-control" type="hidden"/>
                <select name="canteenUid" id="canteenUid"  class="form-control" type="text"
                        required></select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">餐厅状态：</label>
            <div class="col-sm-10">
                <div class="radio-box" th:each="dict : ${@dict.getType('farm_state')}">
                    <input type="radio" th:id="${'canteenState_' + dict.dictCode}" name="canteenState"
                           th:value="${dict.dictValue}" th:field="*{canteenState}" required>
                    <label th:for="${'canteenState_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">名称：</label>
            <div class="col-sm-10">
                <input name="canteenName" id="canteenName" th:field="*{canteenName}" class="form-control" type="text"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">营业时间：</label>
            <div class="col-sm-10">
                <input name="canteenDate" id="canteenDate" th:field="*{canteenDate}" class="form-control" type="text"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">餐厅地址：</label>
            <div class="col-sm-10">
                <input name="canteenHost" id="canteenHost" th:field="*{canteenHost}" class="form-control" type="text"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">经纬度
                ：</label>
            <div class="col-sm-10">
                <input name="lanlat" id="lanlat" class="form-control" th:field="*{lanlat}" required
                       type="text">
                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 经纬度拾取器：<a target="_blank" href="https://lbs.qq.com/getPoint/">点击跳转</a></span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">联系人：</label>
            <div class="col-sm-10">
                <input name="canteenWorker" id="canteenWorker" th:field="*{canteenWorker}" class="form-control"
                       type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">联系电话：</label>
            <div class="col-sm-10">
                <input name="canteenPhone" id="canteenPhone" th:field="*{canteenPhone}" class="form-control" type="text"
                       required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">标签
                ：</label>
            <div class="col-sm-10">
                <input name="canteenLable" id="canteenLable" th:field="*{canteenLable}" class="form-control"
                       type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">封面图：</label>
            <div class="col-sm-10">
                <input id="canteenPic" th:value="*{canteenPic}" type="hidden">
                <div class="upload" action='upload.html' data-num="1" data-value='' id='piclist_canteenPic'></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">轮播图：</label>
            <div class="col-sm-10">
                <input id="canteenPiclist" th:value="*{canteenPiclist}" type="hidden">
                <div class="upload" action='upload.html' data-value='' id='piclist_canteenPiclist'></div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:src="@{/taginput/jquery.tagsinput-revisited.js}"></script>
<th:block th:include="include :: select2-js"/>

<script type="text/javascript">
    var prefix = ctx + "wechat/WxCanteen";


    $("#form-WxCanteen-edit").validate({
        focusCleanup: true
    });

    $.operate.ajaxGet(ctx + "/wechat/user/listAjax", function (result) {
        if(result.data.length==0){
            $.modal.alertError("暂无用户")
        }
        var html = "";
        for (var i = 0; i < result.data.length; i++) {
            html += "<option value='" + result.data[i].userId + "'>" + result.data[i].userName + "</option>";
        }
        $("#canteenUid").append(html);
        $("#canteenUid").val($("#Uid").val())
    })


    $('#canteenLable').tagsInput({
        'unique': true,
        'minChars': 2,
        'maxChars': 30,
        'limit': 4,
        'placeholder': '输入标签内容',
    });
    //轮播图上传
    $("#piclist_canteenPic").attr("data-value", $("#canteenPic").val())
    $("#piclist_canteenPic").upload(function () {
    }, "canteenPic")


    //轮播图上传
    $("#piclist_canteenPiclist").attr("data-value", $("#canteenPiclist").val())
    $("#piclist_canteenPiclist").upload(function () {
    }, "canteenPiclist")


    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-WxCanteen-edit').serialize());
        }
    }
</script>
</body>
</html>
